package iscript.coreFramework.data.pager 
{
	import flash.utils.Dictionary;
	import iscript.coreFramework.data.datatable.DataTable;
	/**
	 * ...
	 * @author raymond
	 */
	public class DataTablePager extends BasePager
	{
		
		public function DataTablePager(record:DataTable) 
		{
			_datasource = record;
			super(record.RowCount);
		}
		
		private var _datasource:DataTable;
		public  function get dataSource():DataTable { return _datasource; }
		
		override public function get recordCount():int 
		{
			return _datasource.RowCount;
		}
		
		
		override public function get pageCount():int 
		{
			var pageCount:int = 0;			   
			   if (recordCount % pageSize == 0) {
				   pageCount = recordCount/pageSize
				   }else {
				   pageCount = recordCount/pageSize+1
				}
			    return  pageCount;
		}
		
		public  function getDataByPageIndex(pageIndex:int):Vector.<Dictionary> {
			 var  number:Array = this.getNumberByPageIndex(pageIndex);			 
			 var  datarow:Vector.<Dictionary> = _datasource.Rows;			 
			 var data:Vector.<Dictionary> = new Vector.<Dictionary>();
			 for each(var i:* in number) {
			   data.push(datarow[i]);
			 }
			  return data;
			}
			
			
	     public function  getDataByCurrentPage():Vector.<Dictionary> {
			var  number:Array = this.getNumberByCurrentPage();
			var  datarow:Vector.<Dictionary> = _datasource.Rows;
			var  data:Vector.<Dictionary> = new Vector.<Dictionary>();
			for each(var i:* in number) {
			     data.push(datarow[i]);
			 }
			  return data;
		   }
		
		
	}

}